# $Id$
# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Maintainer: Antonio Rojas <arojas@archlinux.org>
# Contributor: Andrea Scarpino <andrea@archlinux.org>
# Contributor: Pierre Schmitz <pierre@archlinux.de>

pkgbase=kde-l10n
pkgver=17.08.1
pkgrel=3
arch=(any)
url='https://www.kde.org/'
license=(GPL)
makedepends=(kdelibs cmake automoc4)
options=(docs)

_languages=(
  'ar     "Arabic"'
  'ast    "Asturian"'
  'bg     "Bulgarian"'
  'bs     "Bosnian"'
  'ca     "Catalan"'
  'ca@valencia     "Catalan (Valencian)"'
  'cs     "Czech"'
  'da     "Danish"'
  'de     "German"'
  'el     "Greek"'
  'en_GB  "British English"'
  'eo     "Esperanto"'
  'es     "Spanish"'
  'et     "Estonian"'
  'eu     "Basque"'
  'fa     "Farsi"'
  'fi     "Finnish"'
  'fr     "French"'
  'ga     "Irish"'
  'gl     "Galician"'
  'he     "Hebrew"'
  'hi     "Hindi"'
  'hr     "Croatian"'
  'hu     "Hungarian"'
  'ia     "Interlingua"'
  'id     "Indonesian"'
  'is     "Icelandic"'
  'it     "Italian"'
  'ja     "Japanese"'
  'kk     "Kazakh"'
  'km     "Khmer"'
  'ko     "Korean"'
  'lt     "Lithuanian"'
  'lv     "Latvian"'
  'mr     "Marathi"'
  'nb     "Norwegian Bokmal"'
  'nds    "Low Saxon"'
  'nl     "Dutch"'
  'nn     "Norwegian Nynorsk"'
  'pa     "Panjabi/Punjabi"'
  'pl     "Polish"'
  'pt     "Portuguese"'
  'pt_BR  "Brazilian Portuguese"'
  'ro     "Romanian"'
  'ru     "Russian"'
  'sk     "Slovak"'
  'sl     "Slovenian"'
  'sr     "Serbian"'
  'sv     "Swedish"'
  'tr     "Turkish"'
  'ug     "Uyghur"'
  'uk     "Ukrainian"'
  'wa     "Walloon"'
  'zh_CN  "Chinese Simplified"'
  'zh_TW  "Chinese Traditional"'
)

pkgname=()
source=()

for _lang in "${_languages[@]}"; do
  _locale=${_lang%% *}
  _pkgname=kde-l10n-${_locale,,}
  
  pkgname+=($_pkgname)
  source+=("https://download.kde.org/stable/applications/$pkgver/src/$pkgbase/$pkgbase-$_locale-$pkgver.tar.xz")
  eval "package_$_pkgname() {
    _package $_lang
  }"
done

sha256sums=('c7dceb09a40f3661c6332a416a40ed9c775c5be5b52f559fcf1a28a1a341720d'
            'c7f653b84159ef97367dfb65ec900133757a910f1d4e186067fb728f1ed95e6f'
            'dd3dfa55b4fb9a7d34824fc00e8b4a9ca5e00b670ea8b8ec4f02837870f3e82f'
            'dee30b4c83f4f061a813495669ea1c2724fb66baaf968a1eb0bb2ca31ecf52a6'
            '652aac4e8f9d0fee57e83afa594df826fe892759d18ae9e8fbcce1cf94d4b7d1'
            '94ac3adf0e8e894d730b269ec4d83f7d09245b0e7c7875fc53dbf3250ddbdbb6'
            '41ef06f8a70f77534c7291ca5d09ff4c493e9b0e322385d79b258d302c2d3039'
            'e28550429084ed214fe40ab24362fba008e331af7eddb892f296b7e57e7d2067'
            '8b02bf414e837daedde22ae2ce00344cb04873eff2c5ef2a92414c8241084d21'
            '268de1633ad13c21d0eef02a2f3c5492d47ab2e5b616396201d6d7e775464ed4'
            'ce7735bc3ba4024dd55b623aaf7b01c84642ca0bc696acc6db9a3060da441493'
            '6649fcfcdecf724ba6ce47a249a6bc4940d2b74ad689e48ceb333d0844999616'
            '06c96bb395c78d4f6d8065c5ba5ecb70f1de6a9f32b5e280799ee5f283fe54c0'
            'bc74511ca7ff660ac9f014e7c1f91c8b7cb898f3a46210edb2cf1c160dd3cc45'
            '3407e0c94f448b1ac581a50f48a03d5371154f77da058f1b715252da96f0b5db'
            'ac62bfd0b2c2b7c7a02100d56b343de4749516139ae24c4357ef307f99faa6a7'
            '6af5d1dfb623db119c8f78164321112cab2d10561232c2470fddc29465d68d11'
            '0f46190c9c7aaedf05e0f21e933df6da26130eb56a3baad6b85790a74bc81237'
            'fa9591dff143c3a3c8317558d60b2ecaab7f7ba4149268e5a0f53971e35c7751'
            '48c843aa21f7dc1d533870e686598bb92bc2320153309607ef1fde82943f6fad'
            '5d7188e9ae02db67272d0c6eb6f0c2ccaa9facea4df0e214e2829e11c5fe94c0'
            'b4ed79dc0000417bd6b065363c7b5e04d25d149624a1b82bd5eb89033c644b7e'
            'bbefc87da57ea07c6a90748076d3c0514268af11325a81b2d7e662ce80fd9fcc'
            '9a391c0a5f0631e695876887b684e47a2cdef7d8fa1db603759a9ab4df0342ca'
            'a2e71d83365bd094818611b47606f7c30780afac0e30a946c359add564b8152c'
            '459cf867e16229c4d92b9c10a365deea731fa17d47a527cd68e6eaca1f2bbcc1'
            '6a341373f16c896392e82c12c63a1beaf1e9e598ff6557c44d873997c745385d'
            'df4755f853b690bd560122a7f85530e6d32cc6f4b25ee6f0cb6060f3dc0ec3a9'
            '5d8bb99104a3e37d661320be0a52037611e80f6f7b678c9cbee8aa5143cde388'
            '3f3285f983de115fe157403145170f153ff007168a23def310daad71cc859397'
            'fa92c6636597096f030b284d63394897fe1bcee2abb78fbf0ab5b9e886dfcbb0'
            '38d7ace48720c681bf57d706e7a590ce3fa29ed707f71fc950fb3e4b9b94b673'
            'ca4cfbe7d2756d2dc51889583e11c34de03105fb4bf8f7fef03e435b410da708'
            '91f392e875ad4d6b133167800699add1a110aa759852b8fd2f5499b2f0d3b09f'
            '0cb3a724c2eac4104daefd7222c205276b3bf3101114fa4f5a7afa1cd8b51e5d'
            '679bcdb7a4d47997993d668f2f4b99a9d55dc70e962258af5b84d322af3370c6'
            '9ee9a455dab2335ea1e91f5cd97a182a9b4bffb90f9a31f864417eb55151ed3c'
            'c56d9394fa97278bf34dd0a3208a66a6afd481ed752ad017a9d7454c964d0534'
            '309b359fc0550f00019a47ce037608362c20c764fd9d139bf136c7ea2338850c'
            '1dcb02017725c3c4553e52fb1c547ed7dddf5a6998e459664fa3e6aa1e130781'
            '7c647862e8bd7e28c71ef1c78cc3a3ebb6e9801ea389780366eb136f594d772f'
            '1bba997272334d75ae10700781931db30a6362ea5666402447937f1cc350c154'
            '08bb8826b6686b9a46340dac5d11405fce31eaec2f2189da9db6c5d26fce07ce'
            '6c3d26deaf3ff765e0325cb666bedc61b6239a739e2c00e28c305f9bbe5c6911'
            '026a9a475c4483879fe74618f6daaf73786d943b99cd95cba15728165c4ffd13'
            '01ecde2251751d8680456e10695562dc0fbb0e53e39ab2b9e32e56645f9c9e60'
            '084c0648e04d12beb240188bba079e0dbbf67a71e1e682c8f6705d2a9d30ab8e'
            'acb41f5e2442429c26fc2154fac6b2ca68d519d8ee5f22d02b16e751d7bb8675'
            '8625182b5b4c3b8db6bc6457e59c856ce1001cd8bb90b1757ffb3430223f065c'
            '9da98d077ed19a97108788472e6efdec3ca3cc0f9f958eff6fb6828082c8a297'
            'bc785de8aa0b999faaa23b195ccbe577361f022c362654c69b9136b4e530edae'
            'e92b322ff2dd7de9f9d4a20b85eaa1c4e6e211cf7f6093907d033c044ab55ef9'
            '1b8af76a11e8bf578f0241fda6b1c5f0893c5ff36e9a2e339461e81f1bbf8708'
            '2e29f6e92e5344cbba519c80317c407736c861d104785644c6b0cf8bdc8ca828'
            '2c4f47365752f19366a42a40ac21e8be2c69bd0f65c548fcc67ae04dca78930a')

build() {
  for _lang in "${_languages[@]}"; do
    _locale=${_lang%% *}
    
    mkdir -p build/$_locale
    cd build/$_locale
    cmake $srcdir/$pkgbase-$_locale-$pkgver \
      -DCMAKE_BUILD_TYPE=Release \
      -DCMAKE_INSTALL_PREFIX=/usr
    make
    cd ../..
  done
}

_package() {
  pkgdesc="$2 localization for KDE4 Applications"
  cd build/$1
  make DESTDIR="$pkgdir" install

# Fix conflicts
  rm -fr "$pkgdir"/usr/share/doc/HTML/*/{kdesu,knetattach,kcontrol,fundamentals,khelpcenter,onlinehelp}
  rm -fr "$pkgdir"/usr/share/man/*/man1/kdesu.1
}
